package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.AnalysisManageOperateLog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * created by wangjunfu on 2021-02-24 15:58:37
 */
public class AnalysisManageOperateLogDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(AnalysisManageOperateLogDao.class);

    public AnalysisManageOperateLog insert(final AnalysisManageOperateLog analysisManageOperateLog) {
        insert("AnalysisManageOperateLog.insert", analysisManageOperateLog);
        return analysisManageOperateLog;
    }

    public Boolean updateInfoById(final AnalysisManageOperateLog analysisManageOperateLog) {
        return update("AnalysisManageOperateLog.updateInfoById", analysisManageOperateLog) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("AnalysisManageOperateLog.updateInfoByQuery", query) > 0;
    }

    public AnalysisManageOperateLog selectById(final Integer id, final Integer entId) {
        Query query = Query.noPage();
        query.put("id", id);
        query.put("entId", entId);
        return queryForObject("AnalysisManageOperateLog.selectById", query);
    }

    public List<AnalysisManageOperateLog> selectByQuery(final Query query) {
        return queryForList("AnalysisManageOperateLog.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("AnalysisManageOperateLog.countByQuery", query);
    }

    public Boolean deleteById(final Integer id, final Integer entId) {
        AnalysisManageOperateLog analysisManageOperateLog = new AnalysisManageOperateLog();
        //analysisManageOperateLog.setDeleteFlag(1);
        analysisManageOperateLog.setId(id);
        analysisManageOperateLog.setEntId(entId);

        return update("AnalysisManageOperateLog.updateInfoById", analysisManageOperateLog) > 0;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("AnalysisManageOperateLog.deleteById", query) > 0;
    }
}